<?php
namespace app\agent\controller\finance;

use app\agent\controller\Controller;
use app\agent\model\Record as RecordModel;
use app\agent\model\Applet as AppletModel;
use think\facade\View;

/**
 * 流水记录
 */
class Log extends Controller
{
    /**
     * 我的流水
     */
    public function my()
    {
        $model = new RecordModel;
        $list = $model->getList(['user_id' => $this->user['user']['user_id']]);
        $title = '我的流水';
        return View::fetch('index', compact('list','title'));
    }

    /**
     * 用户流水
     */
    public function store()
    {
        $userIds = (new AppletModel)->where('agent_id',$this->user['user']['user_id'])->column('user_id');
        $list = (new RecordModel)->where('user_id','in',$userIds)
            ->with(['user'])
            ->order('record_id','desc')
            ->paginate(['list_rows'=>15,'query' => request()->param()]);
        $title = '用户流水';
        return View::fetch('index', compact('list','title'));
    }
}
